<!--
 * @Descripttion: 群发消息
 * @Author: xiao li
 * @Date: 2020-07-06 12:17:07
 * @LastEditors: xiao li
 * @LastEditTime: 2021-06-01 16:29:02
-->
<template>
    <div class="lb-group-msg">
        <top-nav></top-nav>
        <div class="page-main">
            <el-form @submit.native.prevent :model="groupForm" :rules='groupFormRules' ref='groupForm' label-width="140px">
                <el-form-item label="群发内容" prop='content'>
                    <el-input v-model="groupForm.content" placeholder="请输入群发内容"></el-input>
                </el-form-item>
                <el-form-item label="群发类型" prop='content'>
                    <el-radio-group v-model="groupForm.type">
                        <!-- <el-radio :label="0">所有人</el-radio>
                        <el-radio :label="1">仅用户</el-radio> -->
                        <el-radio :label="2">员工</el-radio>
                    </el-radio-group>
                </el-form-item>
                <el-form-item>
                    <lb-button :loading="btnLoading" type='primary' @click="submitFormInfo">{{$t('action.submit')}}</lb-button>
                </el-form-item>
            </el-form>
        </div>
    </div>
</template>

<script>
export default {
  data () {
    return {
      btnLoading: false,
      groupForm: {
        content: '',
        type: 2
      },
      groupFormRules: {
        content: {required: true, type: 'string', message: '请输入内容', trigger: 'blur'},
        type: {required: true, type: 'number', message: '请选择类型', trigger: 'change'}
      }
    }
  },
  created () {
    // this.getFormInfo()
  },
  methods: {
    submitFormInfo () {
      this.$refs['groupForm'].validate(valid => {
        if (valid) {
          let {groupForm} = this
          this.btnLoading = true
          this.$api.appSettingGroupPushMsg(groupForm).then(res => {
            console.log(res)
            this.btnLoading = false
            if (res.code === 200) {
              this.$message.success(this.$t('tips.successSub'))
            }
          }).catch(() => {
            this.btnLoading = false
          })
        }
      })
    },
    getFormInfo () {
      this.$api.appSettingGroupPushMsg().then(res => {
        console.log(res)
      })
    }
  }
}
</script>

<style lang="scss" scoped>
    .lb-group-msg{
        width: 100%;
        .page-main{
            .el-input{
                width: 300px;
            }
        }
    }
</style>
